package com.nursing.Dao;

import com.nursing.bean.DutySchedule;
import com.nursing.model.dto.DutyDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DutyScheduleDao {
    @Select("SELECT ds.*,n.name FROM duty_schedule as ds LEFT JOIN nurse n ON ds.nurse_id = n.id where ds.nurse_id = #{nurseId}")
    public List<DutyDto> getDutyListByNurseId(Integer nurseId);

    @Select("SELECT ds.*,n.name FROM duty_schedule as ds LEFT JOIN nurse n ON ds.nurse_id = n.id; ")
    public List<DutyDto> getDutyList();

    // 添加
    @Select("INSERT INTO duty_schedule (nurse_id, duty_date, duty_type,status) " +
            "VALUES (#{nurseId}, #{dutyDate}, #{dutyType}, #{status})")
    public void addDutySchedule(DutySchedule dutySchedule);

    // 删除
    @Select("DELETE FROM duty_schedule WHERE id = #{id}")
    public void deleteDutySchedule(int id);

    @Select("UPDATE duty_schedule SET status = #{status} WHERE id = #{id}")
    public void editStatus(DutySchedule dutySchedule);
}
